package org.example.longarrays;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        findNumberOfLIS(new int[]{2,2,2,2,2});
    }

    public static void findNumberOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        int[] count  = new int[nums.length];
        Arrays.fill(dp,1);
        Arrays.fill(count,1);
        for(int i=1;i<nums.length;i++){
            for(int j=0;j<i;j++){
                if(nums[i]>nums[j]){
                    if(dp[j]+1>dp[i]){
                        dp[i] = dp[j]+1;
                        count[i]=count[j];
                    }else if(dp[j]+1==dp[i]){
                        count[i]+=count[j];
                    }
                }
            }
        }
        System.out.println(Arrays.toString(dp));
        System.out.println(Arrays.toString(count));
        int max = 0;
        int result = 0;
        for(int i=0;i<nums.length;i++){
            if(dp[i]>max){
                max = dp[i];
                result = count[i];
            }else if(dp[i]==max){
                result += count[i];
            }
        }
        System.out.println(result);


    }
}
